<template>
    <div>
        <h1>管理员登录表</h1>
        <table class="table">
            <tbody>
                <tr>
                    <td>管理员姓名</td>
                    <td><input type="text" v-model="data.name"></td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td><input type="password" v-model="data.pwd"></td>
                </tr>
                <tr>
                    <td colspan="2"><input type="button" value="登录" @click="login"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts"> 
import {ref} from 'vue'
import axios from 'axios'
import { useRouter } from 'vue-router'

const router=useRouter()

const data = ref({
    name:"",
    pwd:""
})

const login = ()=>{
    axios.get("https://localhost:7086/api/Member/LoginMember",{params:data.value}).then(res=>{
        if(res.data==-1)
    {
         alert("管理员用户名称不正确")
         return;
    }
    if(res.data==-2)
    {
        alert("密码不正确")
         return;
    }
    if(res.data==3)
    {
         alert("登录成功")
         router.push({path:"/show"})
         return;
    }
    })
}


</script>

<style scoped>

</style>